package com.spic.business.informatization.before_after_work.service.impl;

import com.spic.business.informatization.before_after_work.domain.MeetingBeforWorkSearchRecord;
import com.spic.business.informatization.before_after_work.mapper.MeetingBeforWorkSearchRecordMapper;
import com.spic.business.informatization.before_after_work.service.MeetingBeforWorkSearchRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 班前班后会会议地点搜索记录框Service业务层处理
 *
 * @author yangjie
 * @date 2021-11-24
 */
@Service
public class MeetingBeforWorkSearchRecordServiceImpl implements MeetingBeforWorkSearchRecordService
{
    @Autowired
    private MeetingBeforWorkSearchRecordMapper meetingBeforWorkSearchRecordMapper;

    /**
     * 查询班前班后会会议地点搜索记录框
     *
     * @param id 班前班后会会议地点搜索记录框主键
     * @return 班前班后会会议地点搜索记录框
     */
    @Override
    public MeetingBeforWorkSearchRecord selectMeetingBeforWorkSearchRecordById(String id)
    {
        return meetingBeforWorkSearchRecordMapper.selectMeetingBeforWorkSearchRecordById(id);
    }

    /**
     * 查询班前班后会会议地点搜索记录框列表
     *
     * @param meetingBeforWorkSearchRecord 班前班后会会议地点搜索记录框
     * @return 班前班后会会议地点搜索记录框
     */
    @Override
    public List<MeetingBeforWorkSearchRecord> selectMeetingBeforWorkSearchRecordList(MeetingBeforWorkSearchRecord meetingBeforWorkSearchRecord)
    {
        return meetingBeforWorkSearchRecordMapper.selectMeetingBeforWorkSearchRecordList(meetingBeforWorkSearchRecord);
    }
    //查询 // 类型: 1会议地点
    @Override
    public Map<String, Object> selectMeetingBeforWorkSearchRecordMap( Long deptId)
    {
        // 类型: 1会议地点
        Map<String, Object> map = new HashMap<>();
        MeetingBeforWorkSearchRecord meetingBeforWorkSearchRecord = new MeetingBeforWorkSearchRecord();
        meetingBeforWorkSearchRecord.setType("1");
        meetingBeforWorkSearchRecord.setDeptId(deptId);
        List<MeetingBeforWorkSearchRecord> meetingPlace = meetingBeforWorkSearchRecordMapper.selectMeetingBeforWorkSearchRecordList(meetingBeforWorkSearchRecord);
        map.put("meetingPlace",meetingPlace);
        return map;
    }

    /**
     * 新增班前班后会会议地点搜索记录框
     *
     * @param meetingBeforWorkSearchRecord 班前班后会会议地点搜索记录框
     * @return 结果
     */
    @Override
    public int insertMeetingBeforWorkSearchRecord(MeetingBeforWorkSearchRecord meetingBeforWorkSearchRecord)
    {

        if(meetingBeforWorkSearchRecord!=null){
            List<MeetingBeforWorkSearchRecord> meetingBeforWorkSearchRecords = meetingBeforWorkSearchRecordMapper.selectMeetingBeforWorkSearchRecordList(meetingBeforWorkSearchRecord);
            if(meetingBeforWorkSearchRecords!=null && meetingBeforWorkSearchRecords.size()>0){
                return 0;
            }
        }
        int count = meetingBeforWorkSearchRecordMapper.insertMeetingBeforWorkSearchRecord(meetingBeforWorkSearchRecord);
        return count;
    }

    /**
     * 修改班前班后会会议地点搜索记录框
     *
     * @param meetingBeforWorkSearchRecord 班前班后会会议地点搜索记录框
     * @return 结果
     */
    @Override
    public int updateMeetingBeforWorkSearchRecord(MeetingBeforWorkSearchRecord meetingBeforWorkSearchRecord)
    {
        return meetingBeforWorkSearchRecordMapper.updateMeetingBeforWorkSearchRecord(meetingBeforWorkSearchRecord);
    }

    /**
     * 批量删除班前班后会会议地点搜索记录框
     *
     * @param ids 需要删除的班前班后会会议地点搜索记录框主键
     * @return 结果
     */
    @Override
    public int deleteMeetingBeforWorkSearchRecordByIds(Long[] ids)
    {
        return meetingBeforWorkSearchRecordMapper.deleteMeetingBeforWorkSearchRecordByIds(ids);
    }

    /**
     * 删除班前班后会会议地点搜索记录框信息
     *
     * @param id 班前班后会会议地点搜索记录框主键
     * @return 结果
     */
    @Override
    public int deleteMeetingBeforWorkSearchRecordById(Long id)
    {
        return meetingBeforWorkSearchRecordMapper.deleteMeetingBeforWorkSearchRecordById(id);
    }
}
